<?php
/**
 * 手机类
 * @describe 详细的功能描述
 * @date: 2018/1/18
 * @time: 15:04
 */

namespace builder;


class Phone implements ProductInterface
{
    /**
     * 名称
     * @var string
     */
    private $_name = '';
    /**
     * 屏幕
     * @var string
     */
    private $_screen = '';
    /**
     * 处理器
     * @var string
     */
    private $_cpu = '';
    /**
     * 内存
     * @var string
     */
    private $_ram = '';
    /**
     * 储存
     * @var string
     */
    private $_storage = '';
    /**
     * 相机
     * @var string
     */
    private $_camera = '';
    /**
     * 系统
     * @var string
     */
    private $_os = '';
    
    /**
     * 构造函数
     * @param string $name     名称
     * @param array  $hardware 构建硬件
     * @param array  $software 构建软件
     */
    public function __construct($name='', $hardware=array(), $software=array())
    {
        // 名称
        $this->_name = $name;
        echo $this->_name . " 配置如下：\n";
        // 构建硬件
        $this->hardware($hardware);
        // 构建软件
        $this->software($software);
    }

    /**
     * 构建硬件
     * @param $hardware array 硬件配置
     * @return void
     * */
    public function hardware(array $hardware = [])
    {
        // 创建屏幕
        $this->_screen  = new HardwareScreen($hardware['screen']);
        // 创建cpu
        $this->_cpu     = new HardwareCpu($hardware['cpu']);
        // 创建内存
        $this->_ram     = new HardwareRam($hardware['ram']);
        // 创建储存
        $this->_storage = new HardwareStorage($hardware['storage']);
        // 创建摄像头
        $this->_camera  = new HardwareCamera($hardware['camera']);
    }

    /**
     * 构建软件
     * @param $software array 软件参数
     * */
    public function software(array $software = [])
    {
        // 创建操作系统
        $softwareOs = new SoftwareOs();
        $this->_os = $softwareOs->produce($software['os']);
    }
}